<!DOCTYPE HTML><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	
<title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
	<div class="content-box-header">
		<h3><? echo $title ?></h3>
		<div class="clear"></div>
	</div> <!-- End .content-box-header -->
	<div class="content-box-content">
<?
  switch ($do) {
    case "add":
    	add();
    	break;
	case "update":
		update($info);
		break;
	case "delete":
		delete($id);
		break;
    default:	
		show_info($info);
  }
?>
<? function show_box($row, $iseditmode, $isadd){ 
	global $id, $baseurl, $url, $title, $h, $cate, $lang, $option, $arrlang;
?>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
      <tr class="th"><td class="thtitle" width="25%" align="right"><? echo $title ?></td><td><input value="<?php echo decode($row["id"]) ?>" name="id" type="hidden"></td></tr>
      <tr><td class="l"><?=ROOT_NAME?></td><td><input value="<?php echo decode($row["name"]) ?>" name="name" type="text" class="g"></td></tr>
      <tr><td class="l"><?=ROOT_LINK?></td><td><input value="<?php echo decode($row["link"]) ?>" name="link" type="text" class="g"></td></tr>
      <? 
      $hide='';
      if(! $option['link']['pic']) $hide=' class="hide" '; ?>
      <tr <? echo $hide ?>><td class="l"><?=ROOT_PICTURE?></td><td>
      <? if(!$isadd)echo '<img src="'.$baseurl.'upload/'.decode($row["pic"]).'" width="240" />'; ?>
      <input name="cpic" type="file" value=""></td></tr>
      <tr><td class="l"><?=ROOT_LANGUAGE?></td><td><? echo $h->select('language_id', $row["language_id"], $arrlang, 'id', 'name', 'g') ?></td></tr>
      <tr><td class="l"><?=ROOT_ORDER?></td><td><? echo $h->text('seq_no',$row['seq_no'],'gs'); ?> <span class="red"> <?=ROOT_HIGHER_NUMBER_IN_FRONT?></span></td></tr>
      <tr><td class="l">&nbsp;</td><td><br><input <? if(!$iseditmode)echo "class='hide'";?> type="submit" value="&nbsp; <?=ROOT_SAVE?> &nbsp;">&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
    </table>
    <? } ?>
	<? function show_boxes($result){
		global $page, $pages, $cateid, $baseurl, $url, $arrlang;
		$str= '<table width="99%" cellspacing="0" cellpadding="3" class="mlist" id="picbox"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_NAME.'</strong></td><td><strong>'.ROOT_LINK.'</strong></td><td><strong>'.ROOT_LANGUAGE.'</strong></td><td><strong>'.ROOT_ORDER.'</strong></td>
		<td><a href="'.$url.'.php?do=add">[ '.ROOT_ADD.' ]</a></td></tr>';
		$count=1;
    	foreach($result as $row)
		{
			$temid=decode($row['id']);
			$temlang=$arrlang[$row['language_id']]['name'];
      		$str.="<tr><td>".$row['id'].".</td><td><a href=\"$url.php?do=update&id=".$temid."\">".decode($row['name'])."</a></td><td>".decode($row['link'])."</td><td>".$temlang."</td><td>".decode($row['seq_no'])."</td><td>";
			$str.="<a href=\"$url.php?do=update&id=".$temid."\">".ROOT_UPDATE."</a> | <a href=\"$url.php?do=delete&id=".decode($row['id'])."\" onClick=\"return delc();\">".ROOT_DELETE."</a></td></tr>";
			$count++;
		}
		$str.="</table>";
		if($count==1) $str.= "<br>".ROOT_NO_DATA."!";
		echo $str;
		echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
    } ?>
    <br class="clear" />
	</div> <!-- End .content-box-content -->
    <br class="clear" />
	</div><!-- End .content-box -->
</body>
</html>
